package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 攻略分类管理
 */
@Getter@Setter
@JsonIgnoreProperties({"handler","json"})
public class StrategyCatalog extends BaseDomain{
    //分类名称
    private String name;
    //攻略
    private Strategy strategy;
    //序号 排序
    private Integer sequence;
    //状态
    private Boolean state;

    //关联属性 一对多  文章信息集合
    private  List<StrategyDetail> details = new ArrayList<>();



    /**
     * 增加一个属性 json对象
     * @return
     */
    public String getJson() {
        Map<String,Object> map= new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if(strategy!=null){
            map.put("strategyId",strategy.id);
            map.put("strategyTitle",strategy.getTitle());
        }
        return JSONUtil.toJSONString(map);
    }


}